#ifndef EDITUSERDLG_H
#define EDITUSERDLG_H

#include <QDialog>
#include <QTextEdit>
#include <QDebug>
#include <QMessageBox>
#include <component/multiselectcombobox.h>
#include <api/systemManager/usermanagerapi.h>
//#include <Entity/DictData.h>
//#include <Entity/TreeSelect.h>
#include <router/systemManager/userManager/usermanager.h>


namespace Ui {
class EditUserDlg;
}

class EditUserDlg : public QDialog
{
    Q_OBJECT

public:
    explicit EditUserDlg(int userId,QWidget *parent = nullptr);
    ~EditUserDlg();

public slots:
    void getParam(QList<TreeSelect> *deptTreeList,
                  QString initPassword,
                  QList<DictData> *dictDataList,
                  QList<DictData> *sexDataList);
private slots:

    void deptTreeClicked();

    void on_btn_cancle_clicked();

    void on_btn_editUser_dept_clicked();

    void on_btn_ok_clicked();
signals:
    void addSuccess();

private:
    Ui::EditUserDlg *ui;

    QNetworkReply *reply;
    void initDlg();
    void getUserById();
    void setUserInfo();
    //隐藏,或显示掉表格布局的一行
    void hideRow(QGridLayout *gridLayout,int row, bool bEnable);
    //设置部门树
    void setDeptTree(QList<TreeSelect> *deptTreeList,QTreeWidgetItem *menu);

    //标记部门是否修改过
    bool deptChangedFlag = 0;
    //备注栏
    QTextEdit *textEdit;
    int userId;
    User *user;
    UserManagerApi userManagerApi;
    MultiSelectComboBox *postBox;
    MultiSelectComboBox *roleBox;
    Utils utils;
    QList<Role> roles;
    QList<Post> posts;
    QList<int> postIds;
    QList<int> roleIds;
    QList<TreeSelect> *deptTreeList;
    QString initPassword;
    QList<DictData> *dictDataList;
    QList<DictData> *sexDataList;
    QTreeWidget *treeWidget;
};

#endif // EDITUSERDLG_H
